<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
// 下面要做的就是把这个页面 写到 uniapp 里面去 让app可以直接扫码 不要模拟进入了 我得给个header限制 不让web登陆 只能让app登陆
{{ host }} : {{ port }}
<script>
    let user_id = 17;

    function GeneratorMessage(prototype, json_message) {
        return JSON.stringify({
            type: prototype,
            message: json_message,
            send_time: parseInt(new Date().getTime())
        })
    }

    let ws = new WebSocket("ws://192.168.0.107:6789");
    ws.onopen = () => {
        let prototype = 4001;
        let json_message = {
            host: "{{ host }}",
            port: "{{ port }}",
            user_info: {
                "user_id": user_id,
            }
        };
        let data = GeneratorMessage(prototype, json_message);
        ws.send(data)
    };
    ws.onclose = () => {
    };
    ws.onmessage = () => {
    };
    ws.onerror = () => {
    };
</script>
</body>
</html>